<?php   
    if (isset($_SERVER['SCRIPT_FILENAME']) && 'comments.php' == basename($_SERVER['SCRIPT_FILENAME']))   
        die ('Please do not load this page directly. Thanks!');   
?>
<section class="modal-content-hack comments-header">
	<div class="comments-header-info">
	  <span><?php echo '评论数量:'.gamux_comment_user($post->ID, 1).'条'; ?></span>
	  <span><?php echo '评论人数:'.gamux_comment_user($post->ID).'(不计游客)'; ?></span>
	</div>
	<div class="comments-header-select">
	  <button type="button" class="btn btn-default sort-select" alt="all">全部</button>
	  <button type="button" class="btn btn-primary sort-select" alt="download">资源分享</button>
	  <button type="button" class="btn btn-info sort-select" alt="faq">问题互动</button>
	  <button type="button" class="btn btn-danger sort-select" alt="evaluation">游戏测评</button>
	  <button type="button" class="btn btn-warning">组织汉化？点此招募</button>
	</div>
</section>
<section class="comments-list">
<!-- 显示评论列表 -->
<?php    
if (!empty($post->post_password) && $_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {    
   // if there's a password   
   // and it doesn't match the cookie   
?>   
<li class="decmt-box">   
   <p><a href="#addcomment">请输入密码再查看评论内容.</a></p>   
</li>   
<?php    
   } else if ( !comments_open() ) {   
?>   
<li class="decmt-box">   
   <p><a href="#addcomment">评论功能已经关闭!</a></p>   
</li>   
<?php    
   } else if ( !have_comments() ) {    
?>   
<li class="decmt-box">   
   <p><a href="#addcomment">还没人评论，说两句吧！</a></p>   
</li>   
<?php    
   } else {
		echo '<div id="accordion" role="tablist" aria-multiselectable="true">';
	    wp_list_comments('callback=gamux_comment&reverse_top_level=false');   
   }    echo '</div>';
?>
</section>
<!--评论框部分-->
<li class="divider-weight"></li>
<section class="comments-textarea">
<?php 
if(comments_open()) {
	if(get_option('comment_registration') && !$user_ID) {
		echo '请<a href="'.get_option('siteurl').'/wp-login.php?redirect_to='.urlencode(get_permalink()).'">登录</a>后再评论！';
	}
	else {	
?>
<div id="respond" class="comment-respond">
  <form id="comment_form" action="<?php bloginfo('siteurl'); ?>/wp-comments-post.php" method="post">
	<div class="input-comment-info">
    <?php if( is_user_logged_in() ){ ?>
	  <span class="comment-form-author">
	    <label for="author" class="sr-only">昵称</label>
		<input id="author" name="author" placeholder="*登陆后不可输入昵称" disabled="disabled" value="<?php echo $current_user->display_name; ?>" type="text">
	  </span>
	  <span class="comment-form-email">
	    <label for="email">电子邮件</label> 
		<input id="email" name="email" value="<?php echo $current_user->user_email; ?>" size="30" type="text">
	  </span>	  
	<?php  } else{ ?>
	  <span class="comment-form-author">
	    <label for="author" class="sr-only">昵称</label>
		<input class="form-control" placeholder="*请输入一个昵称" id="author" name="author" value="<?php echo get_comment_author(); ?>" type="text">
	  </span>
	  <span class="comment-form-email">
	    <label for="email">电子邮件</label> 
		<input id="email" name="email" value="10010@10086.com" size="30" type="text">
	  </span>	
	<?php } ?>	
	  <span class="comment-form-title">
	    <label for="title" class="sr-only">标题</label>
		<input id="title" class="form-control" placeholder="*请输入一个标题" name="title" value="支持gamux！" type="text">
	  </span>
	  <span class="comment-form-option">
<select name="option" id="option">
<option value="">选择分类</option>
<option value="download">1资源分享</option>
<option value="faq" selected="selected">2问题互动</option>
<option value="evaluation">3游戏测评</option>
</select>
	  </span>
	  <span class="clear"></span>
	</div>
	<?php include(TEMPLATEPATH . '/smiley.php'); ?>
	<p class="comment-form-comment">
	      <?php wp_editor( '', comment, $settings = array(
                    'quicktags'=> 1,
                    'tinymce'=>0,
                    'media_buttons'=>0,
                    'textarea_rows'=>4, 
                    'editor_class'=>"textareastyle form-control"
			) ); ?>
	</p>
	<p class="form-submit">
		<input name="submit" id="submit" value="提交评论" type="submit">
		<?php cancel_comment_reply_link( '取消回复' ); ?>
		<?php if(!is_user_logged_in()) {
				spam_protection_math();
			  }
		?>
		<input name="comment_post_ID" value="<?php echo get_the_ID(); ?>" id="comment_post_ID" type="hidden">
		<input name="comment_parent" id="comment_parent" value="0" type="hidden">
	</p>
  </form>
</div>   		
<?php	}
}
else {
	echo '评论已关闭';
} 
?>

</section>
<script src="<?php bloginfo('template_url'); ?>/library/ajax-comment.js"></script>
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/comments.css" type="text/css">
<script>
//点击按钮切换评论频道
$('.sort-select').click(function() {
	if($(this).attr('alt') == 'all'){
		$("li.comment").css('display', 'block');
	}
	else{
	$("li.comment").css('display', 'none');
	$("li." + $(this).attr('alt')).css('display', 'block');
	
	$("li." + $(this).attr('alt')).children('.comments-main').children('.children').children('li').each(function() {
		$(this).css('display', 'block!important');
	});
	}
});
$('.comments-title a').click(function() {
	$("ul li .comments-main").css({"display":"block", "visibility": "visible"});
});
$(function(){
   $("#submit").bind("click",function(event){
        var title = $("#title").val();
		var option = $('#option').val();//获取元素的值
        if(title == ""){     //判断值是否为空
			alert('标题不可为空');
			return false;
		}
		if(option == ""){
			alert('请选择一个分类');
			return false;
		}
   });
});
$(function(){
	$(".comments-title a").each(function() {
	var len = $(this).parent(".comments-title").parent('.comment').children('.comments-main').children('ul.children').children('li').length;
	$(this).children('.reply-count').children('.reply-count-num').text(len);
	});

});
</script>

  